/* 模板管理
 * @Author: wujie 
 * @Date: 2018-06-12 11:06:22 
 * @Last Modified by: wujie
 * @Last Modified time: 2018-06-27 18:45:15
 */
import React,{ Component } from 'react'
import { Row } from 'antd'
import { connect } from 'react-redux'
import components from '@/components'
import actions from '@/actions/templateEdit'
import util from '@/utils'

const { TemplateEdit: Edit, Card } = components

class TemplateEdit extends Component {

  render(){

    const props = util.pick(this.props, [
      'template', 
      'addButtonLoading', 
      'remark',
    ])

    const funcProps = util.pick(this, [
      'onChangeTemplate',
      'onChangeRemark',
      'onAdd',
    ])
    
    return (
      <div>
        <Card title="模板添加">
          <Row style={{padding:24,backgroundColor: '#fff'}}>
            <Edit {...props} {...funcProps} />
          </Row>
        </Card>
      </div>
    )
  }

  onChangeTemplate = ({target:{ value }}) => {
    this.props.setTemplate(value)
  }

  onChangeRemark = ({target:{ value }}) => {
    this.props.setRemark(value)
  }

  onAdd = () => {
    this.props.add()
  }

} 

const mapStateToProps = ({ templateEditReducer }) => ({ ...templateEditReducer })

const mapDispatchToProps = { ...actions }

export default connect(mapStateToProps, mapDispatchToProps)(TemplateEdit)